<?php
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 *
 * PARAMS:
 *    assign      - assign to variable - otherwirse to 'articles'
 *    type        - coma separated list of types to be in articles
 *    limit       - limit articles
 *    select      - select by order: newest
 *    assignpages - assign pages array to variable
 */


function smarty_function_meccano_gallery($params, &$smarty)
{
   $type   = NULL;
   $images = array();
   $limit  = 5;
   
   foreach($params AS $k=>$value)
   {
      $$k = $value;
   }
   if(!isset($assign)) $assign = 'gallery';
   if(!isset($select)) $select = 'new';

   $gallery = new gallery();


   switch ($select)
   {
      case 'new':
      default:
         $images = $gallery->getNewImages($type, $limit);
   }

   $smarty->assign($assign, $images);
}